package io.finer.erp.base.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.finer.erp.base.entity.BasMaterial;
import io.finer.erp.base.service.IBasMaterialService;
import io.finer.erp.base.service.IBasUnitService;
import io.finer.erp.base.service.IDashboardService;
import io.finer.erp.base.vo.DashboardRequest;
import io.finer.erp.base.vo.PieVO;
import io.finer.erp.base.vo.TrendVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.poi.ss.formula.functions.Trend;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.aspect.annotation.AutoLog;
import org.jeecg.common.system.base.controller.JeecgController;
import org.jeecg.common.system.query.QueryGenerator;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Arrays;
import java.util.List;

/**
 * @Description: 物料
 * @Author: jeecg-boot
 * @Date: 2020-05-29
 * @Version: V1.0
 */
@Api(tags = "物料")
@RestController
@RequestMapping("/base/dashboard")
@Slf4j
public class DashboardController {

    @Autowired
    private IDashboardService dashboardService;

    @GetMapping("orderSourceTrend")
    @ApiOperation("订单来源趋势统计")
    public Result<TrendVO<Integer>> orderSourceTrend(DashboardRequest dashboardRequest) {
        return Result.OK(dashboardService.orderSourceTrend(dashboardRequest));
    }


    @GetMapping("orderTypePie")
    @ApiOperation("订单类型总量统计")
    public Result<PieVO<Integer>> orderTypeCntPie(DashboardRequest dashboardRequest) {
        return Result.OK(dashboardService.orderTypeCntPie(dashboardRequest));
    }

    @GetMapping("orderTypeTrend4Week")
    @ApiOperation("订单本周趋势")
    public Result<TrendVO<Integer>> orderTypeTrend4Week(DashboardRequest dashboardRequest) {
        return Result.OK(dashboardService.orderTypeTrend4Week(dashboardRequest));
    }

    @GetMapping("cntAndTurnover")
    @ApiOperation("销量和营业额")
    public Result<PieVO<Integer>> cntAndTurnover(DashboardRequest dashboardRequest) {
        return Result.OK(dashboardService.cntAndTurnover(dashboardRequest));
    }


}
